<template>
  <div id="app">
    <h2>测试题</h2>
    <subject
      v-for="(result, index) in list"
      :key="index"
      :index="index"
      @result="resultFn"
    ></subject>
    <div>
      <flag
        v-for="(result, index) in list"
        :key="index"
        :result="result"
        :index="index"
      ></flag>
    </div>
  </div>
</template>

<script>
import Subject from "./components/ys";
import Flag from "./components/pd";
export default {
  data() {
    return {
      list: ["未完成", "未完成", "未完成", "未完成", "未完成"], // 保存的是题目做的结果: 值有3种情况 "未完成", "正确", "错误"
    };
  },
  methods: {
    resultFn(resultStr, index) {
      // "正确", "错误"
      this.$set(this.list, index, resultStr); // 把结果更新到list数组中
    },
  },
  components: {
    Subject,
    Flag,
  },
};
</script>